<?xml version="1.0"?>
<ScatterFile xmlns="http://schemas.microsoft.com/netmf/ScatterfileSchema.xsd">

	<!-- CQ_FRK_FM3 -->
	<!-- FM3 Memory Map -->
	<!-- 0x00000000 - 0x000FFFFF	flash memory 1024KB -->
	<!-- 0x1FFF0000 - 0x2000FFFF	RAM 128KB -->

	<Set Name="Use_SRAM" Value="false"/>

	<If Name="TARGETLOCATION" In="FLASH">
		<Set Name="Code_BaseAddress"		Value="0x00000000"/>
		<Set Name="Code_Size"				Value="0x000A0000"/>    
		<Set Name="Deploy_BaseAddress"		Value="0x000A0000"/>    
		<Set Name="Config_BaseAddress"		Value="0x000E0000"/>    
		<Set Name="Config_Size"				Value="0x00001000"/>
		<Set Name="Custom_Heap_Begin"		Value="0x2000D000"/>
		<Set Name="Custom_Heap_End"			Value="0x2000DFF8"/>
		<Set Name="Stack_Bottom"			Value="0x2000E000"/>
		<Set Name="Stack_Top"				Value="0x2000FFF8"/>
		<If Name = "Use_SRAM" Value="true">
			<Set Name="Heap_Begin"				Value="0x60018000"/>
			<Set Name="Heap_End"				Value="0x6007FFF8"/>    
			<Set Name="ER_RAM_RO_BaseAddress"	Value="0x60000000"/>    
        	<Set Name="ER_RAM_RO_Size"			Value="%Heap_Begin%-%ER_RAM_RO_BaseAddress%"/>    
		</If>
		<If Name = "Use_SRAM" Value="false">
			<Set Name="Heap_Begin"				Value="0x20003000"/>
			<Set Name="Heap_End"				Value="0x2000CFF8"/>    
			<Set Name="ER_RAM_RO_BaseAddress"	Value="0x1FFF0000"/>    
        	<Set Name="ER_RAM_RO_Size"			Value="%Heap_Begin%-%ER_RAM_RO_BaseAddress%"/>    
		</If>
        <Set Name="Valid"               	Value="true"/>

<!-- Original assignment
		<Set Name="Heap_Begin"			Value="0x20000000"/>
		<Set Name="Heap_End"			Value="0x20007FF8"/>    
		<Set Name="Custom_Heap_Begin"	Value="0x20008000"/>
		<Set Name="Custom_Heap_End"		Value="0x2000BFF8"/>    
		<Set Name="Stack_Bottom"		Value="0x2000C000"/>
		<Set Name="Stack_Top"			Value="0x2000FFF8"/>
		<Set Name="Code_BaseAddress"	Value="0x00000000"/>
		<Set Name="Code_Size"			Value="0x00080000"/>    
		<Set Name="ER_RAM_RO_BaseAddress"	Value="0x1FFF0000"/>    
		<Set Name="ER_RAM_RO_Size"			Value="%Heap_Begin%-%ER_RAM_RO_BaseAddress%"/>    
        <Set Name="Valid"               	Value="true"/>
-->
	</If>

	<If Name="TARGETLOCATION" In="RAM">
		<Set Name="Heap_Begin"			Value="0x2000E800"/>
		<Set Name="Heap_End"			Value="0x20005FF8"/>    
		<Set Name="Custom_Heap_Begin"	Value="0x20006000"/>
		<Set Name="Custom_Heap_End"		Value="0x20006FF8"/>    
		<Set Name="Stack_Bottom"		Value="0x20007000"/>
		<Set Name="Stack_Top"			Value="0x20007FF8"/>
		<Set Name="Code_BaseAddress"	Value="0x1FFF8000"/>
		<Set Name="Code_Size"			Value="0x0000B800"/>    
		<Set Name="ER_RAM_RO_BaseAddress"	Value="0x1FFF8000"/>    
		<Set Name="ER_RAM_RO_Size"		Value="%Heap_Begin%-%ER_RAM_RO_BaseAddress%"/>    
	</If>

	<NamedGroup Name="MEMORY">
		<LoadRegion Name="LR_%TARGETLOCATION%" Base="%Code_BaseAddress%" Size="%Code_Size%"/>
		<LoadRegion Name="HEAP" Base="%Heap_Begin%" Size="%Heap_End - Heap_Begin% + 1"/>
		<LoadRegion Name="STACK" Base="%Stack_Bottom%" Size="%Stack_Top - Stack_Bottom% + 1"/>
		<LoadRegion Name="RELOC_RAM" Base="%ER_RAM_RO_BaseAddress%" Size="%ER_RAM_RO_Size%"/>
	</NamedGroup>

	<EntryPoint Name="EntryPoint"/>

	<NamedGroup Name="SECTIONS">
		<ExecRegion Name="ER_%TARGETLOCATION%" Options="&gt;LR_%TARGETLOCATION%">
		<FileMapping Name="*" Options="(text.EntryPoint)" />
		<FileMapping Name="*" Options="(SectionForBootstrapOperations)" />
		<FileMapping Name="*" Options="(.text*)" />
		<FileMapping Name="*" Options="(.rodata*)" />
		<FileMapping Name="*" Options="(rodata)" />
		<FileMapping Name="*" Options="(.constdata*)" />
		<FileMapping Name="*" Options="(.conststring*)" />
		<If Name="TARGETLOCATION" In="RAM">     
			<FileMapping Name="*" Options="(SectionForFlashOperations)" />       
		</If>
		<FileMapping Name="*" Options="(SectionForConfig)" />
		<FileMapping Name="*" Options="(.glue*)" />
		<FileMapping Name="*" Options="(locale$$code)" />
		<FileMapping Name="*" Options="(locale$$data)" />
		<Include File="%SPOCLIENT%\Solutions\CQ_FRK_FM3\scatterfile_gcc_missing_symbols.xml"/>
		</ExecRegion>

		<ExecRegion Name="ER_RAM_RO" Align="0x10" Options="&gt;RELOC_RAM AT&gt;LR_%TARGETLOCATION%">
		<If Name="TARGETLOCATION" In="FLASH">     
			<FileMapping Name="*" Options="(SectionForFlashOperations)" />
 		</If>
<!--
		<Include File="%SPOCLIENT%\Solutions\CQ_FRK_FM3\TinyCLR\scatterfile_tinyclr_ram_functions.xml"/>
-->
		</ExecRegion>

		<ExecRegion Name="ER_RAM_RW" Align="0x10" Options="&gt;RELOC_RAM AT&gt;LR_%TARGETLOCATION%">
		<FileMapping Name="*" Options="(rwdata)" />
		<FileMapping Name="*" Options="(.data*)" /> 
		<FileMapping Name="*" Options="(g_PrimaryConfigManager)" />
		</ExecRegion>

		<ExecRegion Name=".bss" Align="0x10" Options="&gt;RELOC_RAM">
		<FileMapping Name="*" Options="(.zidata*)" /> 
		<FileMapping Name="*" Options="(.bss*)" />
		<FileMapping Name="PROVIDE(__exidx_start = .);" />
		<FileMapping Name="PROVIDE(__exidx_end = .);" />
		</ExecRegion>

		<ExecRegion Name="/DISCARD/">
		<FileMapping Name="*" Options="(.ARM.exidx*)" />
		<FileMapping Name="*" Options="(.ARM.extab*)" />
		</ExecRegion>

		<ExecRegion Name="ER_HEAP_BEGIN" Base="%Heap_Begin%">
		<FileMapping Name="*" Options="(SectionForHeapBegin)" />
		</ExecRegion>

		<ExecRegion Name="ER_HEAP_END" Base="%Heap_End%">
		<FileMapping Name="*" Options="(SectionForHeapEnd)" />
		</ExecRegion>

		<ExecRegion Name="ER_CUSTOM_HEAP_BEGIN" Base="%Custom_Heap_Begin%">
		<FileMapping Name="*" Options="(SectionForCustomHeapBegin)" />
		</ExecRegion>

		<ExecRegion Name="ER_CUSTOM_HEAP_END" Base="%Custom_Heap_End%">
		<FileMapping Name="*" Options="(SectionForCustomHeapEnd)" />
		</ExecRegion>

		<ExecRegion Name="ER_STACK_BOTTOM" Base="%Stack_Bottom%">
		<FileMapping Name="*" Options="(SectionForStackBottom)" />
		</ExecRegion>
      
		<ExecRegion Name="ER_STACK_TOP" Base="%Stack_Top%">
		<FileMapping Name="*" Options="(SectionForStackTop)" />
		</ExecRegion>

	</NamedGroup>

	<GlobalVariable Name="Load$$ER_%TARGETLOCATION%$$Base"		Value="ADDR(ER_%TARGETLOCATION%)"/>
	<GlobalVariable Name="Image$$ER_%TARGETLOCATION%$$Length"	Value="SIZEOF(ER_%TARGETLOCATION%)"/>
    
	<GlobalVariable Name="Image$$ER_RAM_RO$$Base"				Value="ADDR(ER_RAM_RO)"/>
	<GlobalVariable Name="Image$$ER_RAM_RO$$Length"				Value="SIZEOF(ER_RAM_RO)"/>
	<GlobalVariable Name="Load$$ER_RAM_RO$$Base"				Value="LOADADDR(ER_RAM_RO)"/>

	<GlobalVariable Name="Image$$ER_RAM_RW$$Base"				Value="ADDR(ER_RAM_RW)"/>
	<GlobalVariable Name="Image$$ER_RAM_RW$$Length"				Value="SIZEOF(ER_RAM_RW)"/>
	<GlobalVariable Name="Load$$ER_RAM_RW$$Base"				Value="LOADADDR(ER_RAM_RW)"/>

	<GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Base"			Value="ADDR(.bss)"/>
	<GlobalVariable Name="Image$$ER_RAM_RW$$ZI$$Length"			Value="SIZEOF(.bss)"/>

	<GlobalVariable Name="__use_no_semihosting_swi"				Value="0"/>
</ScatterFile>
